﻿#include "TwoDHeatMapSettings.h"
#include "ui_TwoDHeatMapSettings.h"
#include <QVBoxLayout>
#include <QPushButton>
#include <QStandardItemModel>
#include <QListWidget>
#include <QStandardItem>

#include "QLabel.h"
#include "QWidget.h"
#include "QTabWidget.h"
#include "QScrollArea.h"

#include "QCheckBox.h"
#include "QComboBox.h"
// #include "ElaMessageButton.h"
// #include "ElaMultiSelectComboBox.h"
#include "QTextEdit.h"
#include "QProgressBar.h"
#include "QRadioButton.h"
#include "QScrollArea.h"
#include "QSlider.h"
#include "QSpinBox.h"
#include "QLabel.h"
// #include "ElaToggleButton.h"
// #include "ElaToggleSwitch.h"
#include "QListView.h"
#include "QScrollBar.h"
// #include "ElaTheme.h"
#include "QLineEdit.h"
#include "QScrollArea.h"
#include <QDoubleSpinBox>
#include "InfomationCurve2DBasical.h"
#include "TextFileParser.h"
#include "BaseWidget/EColorComboBox.h"

#include "BaseModule/IBaseSignal.h"
#include "BaseModule/GlobalHelper.h"
#include "BaseWidget/IdaDialogMsg.h"
#include "DataManager/WindowTotalData.h"
#include "Graph2DWindowBase.h"
#include "PolarCoordinateGraphSettingDialog.h"
#include "FormulaEditorDialog.h"

#include "BaseWidget/IWidgetSignal.h"

namespace
{
    void clearGridLayout(QGridLayout* layout)
    {
        while (layout->count() > 0)
        {
            QLayoutItem* item = layout->takeAt(0); // 获取并移除第一个项目
            if (item)
            {
                QWidget* widget = item->widget();
                if (widget)
                {
                    widget->deleteLater(); // 释放内存
                }
                delete item; // 删除布局项
            }
        }
    }
} // namespace

namespace pst
{
    TwoDHeatMapSettings::TwoDHeatMapSettings(QWidget* parent, Cure2DType type)
        : QTabWidget(parent), m_variableValueIndex(-1), page2RowCount(0), ui(new Ui::TwoDHeatMapSettings()), m_mainWindowId(-1)
    {
        ui->setupUi(this);
        // 设置基本布局属性
        // setFixedWidth(300);
        setContentsMargins(0, 0, 0, 0);
        ui->dockWidget_Data->setStyleSheet("QDockWidget > QWidget{border: 1px solid #EBEDEE;}");
        ui->dockWidget_DataSource->setStyleSheet("QDockWidget > QWidget{border: 1px solid #EBEDEE;}");
        ui->dockWidget_2->setStyleSheet("QDockWidget > QWidget{border: 1px solid #EBEDEE;}");
        ui->dockWidget_3->setStyleSheet("QDockWidget > QWidget{border: 1px solid #EBEDEE;}");
        ui->scrollArea->setStyleSheet("QScrollArea > QWidget{border: 0px solid #EBEDEE;}");
        ui->listView_curveName->setWordWrap(true);
        ui->lineEdit_FormulaEditor->setPlaceholderText(QStringLiteral("self"));

        ui->checkBox_DB->setEnabled(false);
        ui->checkBox_Normalize->setEnabled(false);

        ui->checkBox_MathOperation->setEnabled(false);
        ui->lineEdit_FormulaEditor->setReadOnly(true);
        ui->pushButton_FormulaEditor->setEnabled(false);

        ui->listView_curveName->setContextMenuPolicy(Qt::CustomContextMenu);
        connect(ui->listView_curveName, &QListView::customContextMenuRequested, this, &TwoDHeatMapSettings::slot_showContextMenu);
        connect(ui->listView_curveName->itemDelegate(), &QAbstractItemDelegate::closeEditor, this, &TwoDHeatMapSettings::slot_renameFinished);

        hideComponents();
        m_enableStatus.resize(11);
    }

    TwoDHeatMapSettings::~TwoDHeatMapSettings()
    {
        delete ui;
    }

    void TwoDHeatMapSettings::slot_showContextMenu(const QPoint& pos)
    {
        if(m_isAnimationState) return;
        auto selectionModel = ui->listView_curveName->selectionModel();
        QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
        if (selectedIndexes.isEmpty())
        {
            return;
        }

        // 创建上下文菜单
        QMenu menu(this);

        QAction* deleteAction = new QAction("删除选中的图像", this);
        //QAction* copyAction = new QAction("复制选择的曲线", this);
        //QAction* deleteAllAction = new QAction("删除所有曲线", this);

        // 连接菜单项的触发信号
        connect(deleteAction, &QAction::triggered, this, &TwoDHeatMapSettings::slot_removeSelectedGraph);
        //connect(copyAction, &QAction::triggered, this, [this]()
        //    { emit signal_copySelectedGraph(); });
        //connect(deleteAllAction, &QAction::triggered, this, [this]()
        //    { emit signal_deleteAllCurve(); });

        menu.addAction(deleteAction);
        //menu.addAction(copyAction);
        //menu.addAction(deleteAllAction);

        if (selectedIndexes.size() == 1)
        {
            QAction* renameAction = new QAction("重命名", this);
            connect(renameAction, &QAction::triggered, this, &TwoDHeatMapSettings::signal_renameGraph);
            menu.addAction(renameAction);
        }

        // 在鼠标位置显示菜单
        menu.exec(ui->listView_curveName->viewport()->mapToGlobal(pos));
    }

    void TwoDHeatMapSettings::setMainWindowId(int windowId)
    {
        m_mainWindowId = windowId;
    }

    void TwoDHeatMapSettings::setCurveList(const QList<QString>& curveList)
    {
    }

    QStandardItem* TwoDHeatMapSettings::addCurveToList(const QString& curveName)
    {
        auto item = new QStandardItem(curveName);
        auto model = (QStandardItemModel*)ui->listView_curveName->model();
        item->setCheckable(true);
        item->setCheckState(Qt::Checked);
        model->appendRow(item);
        return item;
    }

    void TwoDHeatMapSettings::clearCurveList()
    {
    }

    void TwoDHeatMapSettings::setCurrentFixedValueIndex(int index)
    {
        m_variableValueIndex = index;
    }

    int TwoDHeatMapSettings::getCurrentVariableValueIndex() const
    {
        return m_variableValueIndex;
    }

    void TwoDHeatMapSettings::updateUILayout()
    {
        _titleFontSize = 14;
        _contentWidth = 290;

        // 添加选项卡UI 数据 显示
        // addTopTabPivotUI();
        // 添加曲线列表UI
        addCurveListUI();
        // 添加变量轴UI
        addVariableAxistUI();
        setVariableValue();
        // 固定值UI
        addFiexedValueToUI();
        setFixedValue();
        // 再设定value列

        ////类别UI
        // addCategaryToUI();
        setCategoryData();
        setDataOptrationUI();
    }

    void TwoDHeatMapSettings::setCategaryData(const QList<QString>& categaryList)
    {
        m_categoryValueList = categaryList;
    }

    QList<QString> TwoDHeatMapSettings::getCategaryData() const
    {
        return m_categoryValueList;
    }

    void TwoDHeatMapSettings::hideCurvePropertylPanel()
    {
        disconnectSignals();
        ui->comboBox_TransverseVariable->clear();
        ui->comboBox_LongitudinalVariable->clear();
        m_fixedCombo.clear();
        clearGridLayout(ui->gridLayout_fixedValue);
        ui->comboBox_valueData->clear();
        ui->checkBox_Normalize->setCheckState(Qt::Unchecked);
        ui->checkBox_DB->setCheckState(Qt::Unchecked);
        ui->checkBox_Normalize->setEnabled(false);
        ui->checkBox_DB->setEnabled(false);
        DisableComponentCombox();
        connectSignals();
    }

    void TwoDHeatMapSettings::setCurvePropertyPanelState(const Info2DPointer& info)
    {
        // ToDO清空面板
        //  变量轴 扫描参数
        // m_variableAxisText->show();
        // m_variableAxisValue->show();
        m_currentTempInfo = info;
        if (info->getReader() == nullptr)
        {
            // TODO 警告
            return;
        }
        // m_variableAxisValue->clear();

        QVector<QString> keyNameList = info->getReader()->getEachColNameOfKey();
        QVector<QVector<double>> keyValueList = info->getReader()->getEachColDataOfKey();
        QVector<QString> _keyUnitList = info->getReader()->getEachColUnitOfKey();
        int currentScanIndex = info->getScanParameterIndex();
        int secondIndex = info->getSecondScanParameterIndex();
        auto valueNameList = info->getReader()->getEachColGroupNameOfValue();

        // 有多个曲线被选择->只判断 扫描参数（变量轴），DB和归一化。
        //  固定值和value列，直接置空

        /*************** 固定值************/
        m_fixedCombo.clear();
        clearGridLayout(ui->gridLayout_fixedValue);
        if (!info->getIsMuti())
        {
            // 添加除去currentScanIndex外的所有key列
            for (int i = 0, index = 0; i < keyNameList.size(); ++i)
            {
                if (i == currentScanIndex || i == secondIndex)
                {
                    continue;
                }
                QLabel* _phiText2 = new QLabel(keyNameList[i], this);
                //_phiText2->setTextPixelSize(_titleFontSize);
                QComboBox* _phiComboBox2 = new QComboBox(this);
                _phiComboBox2->setView(new QListView());
                //_phiComboBox2->setStyleSheet("QComboBox QAbstractItemView { background-color: #FEFEFE; }");

                QVector<double> data = keyValueList[i];
                QStringList _phiComboList2;
                for (int j = 0; j < data.size(); ++j)
                {
                    _phiComboList2.append(QString::number(data[j]));
                }
                _phiComboBox2->addItems(_phiComboList2);
                _phiComboBox2->setFixedSize(QSize(120, 24));

                QLabel* _unitText = new QLabel(_keyUnitList[i], this);
                _unitText->setFixedWidth(30);

                ui->gridLayout_fixedValue->addWidget(_phiText2, index, 0);
                ui->gridLayout_fixedValue->addWidget(_phiComboBox2, index, 1);
                ui->gridLayout_fixedValue->addWidget(_unitText, index, 2);
                index++;
                m_currentFixedValueWidgets.append({_phiText2, _phiComboBox2});
                m_fixedCombo.append(_phiComboBox2);
                // connect(_phiComboBox2, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TwoDHeatMapSettings::slot_updateCurveData);
            }
            // 设置所有key列选中的值
            auto otherKeyData = info->getOtherKeyData();  // otherKeyData中不含扫描参数
            for (int i = 0; i < m_fixedCombo.size(); ++i) // m_fixedCombo.size() = otherKeyData.size()+1
            {
                m_fixedCombo[i]->setCurrentText(QString::number(otherKeyData[i]));
            }
        }

        disconnect(ui->comboBox_TransverseVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
                   this, &TwoDHeatMapSettings::slot_variableAxisChanged);
        disconnect(ui->comboBox_LongitudinalVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
                   this, &TwoDHeatMapSettings::slot_secondVariableAxisChanged);
        /*************** 变量轴************/
        ui->comboBox_TransverseVariable->clear();
        ui->comboBox_LongitudinalVariable->clear();
        if (!info->getIsMuti())
        {
            // 设置变量轴
            // 先设置固定值，然后再设置变量轴（固定值包含变量轴）
            for (int i = 0, index = 0; i < keyNameList.size(); ++i)
            {
                auto getVariableAxisName = keyNameList[i];
                ui->comboBox_TransverseVariable->addItem(getVariableAxisName);
            }
            ui->comboBox_TransverseVariable->setCurrentIndex(currentScanIndex);
            for (int i = 0, index = 0; i < keyNameList.size(); ++i)
            {
                auto getVariableAxisName = keyNameList[i];
                ui->comboBox_LongitudinalVariable->addItem(getVariableAxisName);
            }
            ui->comboBox_LongitudinalVariable->setCurrentIndex(secondIndex);
        }
        else
        {
            auto commanVariableAxisName = info->getCommonFixedNames();
            for (int i = 0, index = 0; i < commanVariableAxisName.size(); ++i)
            {
                ui->comboBox_TransverseVariable->addItem(commanVariableAxisName[i]);
            }
            // 因为多个曲线比较时，使用的第一个曲线为基础，commanVariableAxisName中的个数与keyNameList不一定一致，因此不能使用下标
            auto scanName = keyNameList[currentScanIndex];
            ui->comboBox_TransverseVariable->setCurrentText(scanName);
        }
        m_lastVariableAxisText = ui->comboBox_TransverseVariable->currentText();
        m_lastSecondVariableAxisText = ui->comboBox_LongitudinalVariable->currentText();

        connect(ui->comboBox_TransverseVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
                this, &TwoDHeatMapSettings::slot_variableAxisChanged, Qt::UniqueConnection);
        connect(ui->comboBox_LongitudinalVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
                this, &TwoDHeatMapSettings::slot_secondVariableAxisChanged, Qt::UniqueConnection);

        /*************** value区域************/
        //// 再设定value列

        disconnect(ui->comboBox_valueData, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TwoDHeatMapSettings::slot_resultValueDataChanged);
        ui->comboBox_valueData->clear();
        if (!info->getIsMuti()) // 选择多条曲线的时候，没有
        {
            for (const auto& i : valueNameList)
            {
                ui->comboBox_valueData->addItem(i);
            }
            ui->comboBox_valueData->setCurrentIndex(info->getValueIndex());
        }
        connect(ui->comboBox_valueData, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TwoDHeatMapSettings::slot_resultValueDataChanged);

        if (info->getIsMuti())
        {
            DisableComponentCombox();
        }
        else if (ui->dockWidget_2->isEnabled())
        {
            int valueComponent = info->getValueComponent();
            auto metaStruct = info->getReader()->getDataInfo(info->getValueIndex());
            if (metaStruct.resultDataType == 4)
            {
                DisableComponentCombox();
            }
            else
            {
                QSignalBlocker blocker5(ui->radioButton_RealPart);
                QSignalBlocker blocker6(ui->radioButton_ImaginaryPart);
                QSignalBlocker blocker7(ui->radioButton_Amplitude);
                QSignalBlocker blocker8(ui->radioButton_Phase);

                if (!m_isAnimationState)
                {
                    ui->radioButton_Amplitude->setEnabled(true);
                    ui->radioButton_Phase->setEnabled(true);
                    ui->radioButton_RealPart->setEnabled(true);
                    ui->radioButton_ImaginaryPart->setEnabled(true);
                }
                ui->radioButton_Amplitude->setChecked(false);
                ui->radioButton_Phase->setChecked(false);
                ui->radioButton_RealPart->setChecked(false);
                ui->radioButton_ImaginaryPart->setChecked(false);
                if (valueComponent == 0)
                {
                    ui->radioButton_Amplitude->setChecked(true);
                }
                else if (valueComponent == 1)
                {
                    ui->radioButton_Phase->setChecked(true);
                }
                else if (valueComponent == 2)
                {
                    ui->radioButton_RealPart->setChecked(true);
                }
                else if (valueComponent == 3)
                {
                    ui->radioButton_ImaginaryPart->setChecked(true);
                }
            }
        }

        ui->textEdit_DataSource->setText(info->getDataSources());

        /*************** 数据操作区域************/
        // if (!info.getIsMuti())//单选 2种状态，多选有3种状态
        //{
        //     _checkBoxDB->setTristate(false);
        //     _checkBoxNormalize->setTristate(false);
        // }
        // else
        //{
        //     _checkBoxDB->setTristate(true);
        //     _checkBoxNormalize->setTristate(true);
        // }
        //  设置DB
        if (!m_isAnimationState)
        {
            ui->checkBox_DB->setEnabled(true);
        }
        int isDB = info->getIsDB();
        if (isDB == -1)
        {
            ui->checkBox_DB->setCheckState(Qt::PartiallyChecked);
            ui->checkBox_DB->setTristate(true);
        }
        else if (isDB == 0)
        {
            ui->checkBox_DB->setCheckState(Qt::Unchecked);
            ui->checkBox_DB->setTristate(false);
        }
        else
        {
            ui->checkBox_DB->setCheckState(Qt::Checked);
            ui->checkBox_DB->setTristate(false);
        }
        // 归一化
        if (!m_isAnimationState)
        {
            ui->checkBox_Normalize->setEnabled(true);
        }
        int isNormal = info->getIsNormalized();
        if (isNormal == -1)
        {
            ui->checkBox_Normalize->setCheckState(Qt::PartiallyChecked);
            ui->checkBox_Normalize->setTristate(true);
        }
        else if (isNormal == 0)
        {
            ui->checkBox_Normalize->setCheckState(Qt::Unchecked);
            ui->checkBox_Normalize->setTristate(false);
        }
        else
        {
            ui->checkBox_Normalize->setCheckState(Qt::Checked);
            ui->checkBox_Normalize->setTristate(false);
        }
        //ui->pushButton_FormulaEditor->setEnabled(true);
        /*************** 最后连接槽函数************/
        for (int i = 0; i < m_fixedCombo.size(); ++i) // m_fixedCombo.size() = otherKeyData.size()+1
        {
            //connect(m_fixedCombo[i], QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TwoDHeatMapSettings::slot_updateCurveData);
            connect(m_fixedCombo[i], QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TwoDHeatMapSettings::slot_fixedValueChanged);
        }
    }

    void TwoDHeatMapSettings::on_pushButton_FormulaEditor_clicked()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        QStringList _SelectionCurve{
            QStringLiteral("曲线1"),
        };
        auto _formulaEditorDialog = new FormulaEditorDialog();
        _formulaEditorDialog->setCurveList(_SelectionCurve);
        auto _ok = _formulaEditorDialog->execWindow();
        if (_ok)
        {
            auto _formulaContent = _formulaEditorDialog->getFormulaContent();
            ui->lineEdit_FormulaEditor->setText(_formulaContent);
        }
    }

    void TwoDHeatMapSettings::on_radioButton_Amplitude_clicked()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        auto _isClicked = ui->radioButton_Amplitude->isChecked();
        //ui->checkBox_DB->setEnabled(true);
        //ui->checkBox_DB->setChecked(m_currentTempInfo->getIsDBState());
        //slot_updateCurveData();
        slot_ComplexPartsClicked();
    }
    void TwoDHeatMapSettings::on_radioButton_Phase_clicked()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        auto _isClicked = ui->radioButton_Phase->isChecked();
        //ui->checkBox_DB->setEnabled(false);
        //ui->checkBox_DB->setChecked(false);
        //slot_updateCurveData();
        slot_ComplexPartsClicked();
    }
    void TwoDHeatMapSettings::on_radioButton_RealPart_clicked()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        auto _isClicked = ui->radioButton_RealPart->isChecked();
        //ui->checkBox_DB->setEnabled(false);
        //ui->checkBox_DB->setChecked(false);
        //slot_updateCurveData();
        slot_ComplexPartsClicked();
    }
    void TwoDHeatMapSettings::on_radioButton_ImaginaryPart_clicked()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        auto _isClicked = ui->radioButton_ImaginaryPart->isChecked();
        //ui->checkBox_DB->setEnabled(false);
        //ui->checkBox_DB->setChecked(false);
        //slot_updateCurveData();
        slot_ComplexPartsClicked();
    }

    void TwoDHeatMapSettings::setControlPanelEditable(bool editable)
    {
        ui->comboBox_TransverseVariable->setEnabled(editable);
        ui->comboBox_LongitudinalVariable->setEnabled(editable);
        ui->groupBox_4->setEnabled(editable);
        ui->comboBox_valueData->setEnabled(editable);
        ui->radioButton_Amplitude->setEnabled(editable);
        ui->radioButton_Phase->setEnabled(editable);
        ui->radioButton_RealPart->setEnabled(editable);
        ui->radioButton_ImaginaryPart->setEnabled(editable);
        ui->comboBox_categryValue->setEnabled(editable);
        ui->checkBox_DB->setEnabled(editable);
        ui->checkBox_Normalize->setEnabled(editable);

        // int count = layout->count();
        // for (int i = 0; i < count; ++i)
        //{
        //     QLayoutItem* item = layout->itemAt(i);
        //     if (!item)
        //         continue;

        //    // 如果该项包含一个 widget，则设置其 enabled 为 false
        //    if (QWidget* widget = item->widget())
        //    {
        //        widget->setEnabled(false);
        //    }

        // ui->checkBox_MathOperation->setEnabled(editable);
    }

    QStandardItemModel* TwoDHeatMapSettings::getCurveNameModel()
    {
        QStandardItemModel* model = (QStandardItemModel*)ui->listView_curveName->model();
        return model;
    }

    QListView* TwoDHeatMapSettings::getCurveNameListView()
    {
        return ui->listView_curveName;
    }

    void TwoDHeatMapSettings::setControlPlaneToAnimationState(bool isAnimationState)
    {
        m_isAnimationState = isAnimationState;
        QSignalBlocker blocker5(ui->radioButton_RealPart);
        QSignalBlocker blocker6(ui->radioButton_ImaginaryPart);
        QSignalBlocker blocker7(ui->radioButton_Amplitude);
        QSignalBlocker blocker8(ui->radioButton_Phase);
        if (isAnimationState)
        {
            disconnectSignals();

            m_enableStatus[0] = ui->comboBox_TransverseVariable->isEnabled();
            m_enableStatus[1] = ui->comboBox_LongitudinalVariable->isEnabled();
            m_enableStatus[2] = ui->groupBox_4->isEnabled();
            m_enableStatus[3] = ui->comboBox_valueData->isEnabled();
            m_enableStatus[4] = ui->radioButton_Amplitude->isEnabled();
            m_enableStatus[5] = ui->radioButton_Phase->isEnabled();
            m_enableStatus[6] = ui->radioButton_RealPart->isEnabled();
            m_enableStatus[7] = ui->radioButton_ImaginaryPart->isEnabled();
            m_enableStatus[8] = ui->comboBox_categryValue->isEnabled();
            m_enableStatus[9] = ui->checkBox_DB->isEnabled();
            m_enableStatus[10] = ui->checkBox_Normalize->isEnabled();

            setControlPanelEditable(false);
        }
        else
        {
            connectSignals();

            ui->comboBox_TransverseVariable->setEnabled(m_enableStatus[0]);
            ui->comboBox_LongitudinalVariable->setEnabled(m_enableStatus[1]);
            ui->groupBox_4->setEnabled(m_enableStatus[2]);
            ui->comboBox_valueData->setEnabled(m_enableStatus[3]);
            ui->radioButton_Amplitude->setEnabled(m_enableStatus[4]);
            ui->radioButton_Phase->setEnabled(m_enableStatus[5]);
            ui->radioButton_RealPart->setEnabled(m_enableStatus[6]);
            ui->radioButton_ImaginaryPart->setEnabled(m_enableStatus[7]);
            ui->comboBox_categryValue->setEnabled(m_enableStatus[8]);
            ui->checkBox_DB->setEnabled(m_enableStatus[9]);
            ui->checkBox_Normalize->setEnabled(m_enableStatus[10]);
        }
    }

    void TwoDHeatMapSettings::setDataOprationChanged(bool isLoged, bool isNormalized)
    {
        ui->checkBox_Normalize->setTristate(false);
        ui->checkBox_DB->setTristate(false);
        {
            QSignalBlocker blocker2(ui->checkBox_Normalize); // 开始阻断 signal
            QSignalBlocker blocker1(ui->checkBox_DB);        // 开始阻断 signal
            isLoged ? ui->checkBox_DB->setCheckState(Qt::Checked) : ui->checkBox_DB->setCheckState(Qt::Unchecked);
            isNormalized ? ui->checkBox_Normalize->setCheckState(Qt::Checked) : ui->checkBox_Normalize->setCheckState(Qt::Unchecked);
        }
        slot_updateCurveData();
    }

    void TwoDHeatMapSettings::setResultValueDataChanged(int index)
    {
        {
            QSignalBlocker blocker(ui->comboBox_valueData); // 开始阻断 signal
            ui->comboBox_valueData->setCurrentIndex(index);
            if (!m_currentTempInfo->getIsMuti())
            {
                auto metaStruct = m_currentTempInfo->getReader()->getDataInfo(index);
                if (metaStruct.resultDataType == 4)
                {
                    DisableComponentCombox();
                    ui->checkBox_DB->setEnabled(true);
                    ui->checkBox_DB->setChecked(m_currentTempInfo->getIsDBState());
                }
                else
                {
                    if (!ui->radioButton_Amplitude->isEnabled())
                    {
                        ui->radioButton_Amplitude->setChecked(true);
                    }
                    ui->radioButton_Amplitude->setEnabled(true);
                    ui->radioButton_Phase->setEnabled(true);
                    ui->radioButton_RealPart->setEnabled(true);
                    ui->radioButton_ImaginaryPart->setEnabled(true);
                    if (ui->radioButton_Amplitude->isChecked())
                    {
                        ui->checkBox_DB->setEnabled(true);
                        ui->checkBox_DB->setChecked(m_currentTempInfo->getIsDBState());
                    }
                    else
                    {
                        ui->checkBox_DB->setEnabled(false);
                        ui->checkBox_DB->setChecked(false);
                    }
                }
            }
        }
        slot_updateCurveData();
    }

    QString TwoDHeatMapSettings::getFontFamilyString(const QString& font)
    {
        if (font == "宋体")
        {
            return "SimSun";
        }
        else if (font == "微软雅黑")
        {
            return "Microsoft YaHei";
        }
        return QString();
    }

    void TwoDHeatMapSettings::addTopTabPivotUI()
    {
        //---------- 第一页内容
        m_page1CentralWidget = new QWidget(this);
        m_page2CentralWidget = new QWidget(this);
    }

    void TwoDHeatMapSettings::addCurveListUI()
    {
        ui->listView_curveName->setSelectionMode(QAbstractItemView::ExtendedSelection);
        ui->listView_curveName->setEditTriggers(QAbstractItemView::NoEditTriggers);
        QStandardItemModel* model = new QStandardItemModel(ui->listView_curveName);
        ui->listView_curveName->setModel(model);

        connect(ui->listView_curveName->selectionModel(), &QItemSelectionModel::selectionChanged, this, &TwoDHeatMapSettings::slot_curveNameClicked);
        connect(model, &QStandardItemModel::itemChanged, this, &TwoDHeatMapSettings::slot_curveNameCheckStateChanged);
    }

    void TwoDHeatMapSettings::addVariableAxistUI()
    {
        ui->comboBox_TransverseVariable->setView(new QListView()); // 用于样式
    }

    void TwoDHeatMapSettings::setFixedValue()
    {
        for (int num = 0, index = 0; num < m_FixedVariableValueList.size(); num++)
        {
            if (num == m_variableValueIndex)
            {
                continue;
            }

            const auto& i = m_FixedVariableValueList[num];
            QLabel* _phiText2 = new QLabel(i.first, this);
            //_phiText2->setTextPixelSize(_titleFontSize);
            QComboBox* _phiComboBox2 = new QComboBox(this);
            _phiComboBox2->setView(new QListView());
            QStringList _phiComboList2{i.second};
            _phiComboBox2->addItems(_phiComboList2);
            _phiComboBox2->setFixedSize(QSize(150, 24));

            ui->gridLayout_fixedValue->addWidget(_phiText2, index, 0);
            ui->gridLayout_fixedValue->addWidget(_phiComboBox2, index++, 1);
            m_currentFixedValueWidgets.append({_phiText2, _phiComboBox2});
        }
    }

    void TwoDHeatMapSettings::setVariableValue()
    {
        for (const auto& i : m_FixedVariableValueList)
        {
            ui->comboBox_TransverseVariable->addItem(i.first);
        }
        ui->comboBox_TransverseVariable->setCurrentIndex(m_variableValueIndex);
    }

    void TwoDHeatMapSettings::addFiexedValueToUI()
    {
        ui->scrollArea_fixedValue->setWidgetResizable(true);
        // ui->scrollArea_fixedValue->setFixedHeight(100);
        ui->scrollArea_fixedValue->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        ui->scrollArea_fixedValue->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    }

    void TwoDHeatMapSettings::setCategoryData()
    {
        for (const auto& i : m_categoryValueList)
        {
            ui->comboBox_categryValue->addItem(i);
        }
    }

    void TwoDHeatMapSettings::setDataOptrationUI()
    {
        connect(ui->checkBox_Normalize, &QCheckBox::clicked, this, &TwoDHeatMapSettings::slot_checkBoxNormalizeClicked);
        connect(ui->checkBox_DB, &QCheckBox::clicked, this, &TwoDHeatMapSettings::slot_checkBoxDBClicked);
    }

    void TwoDHeatMapSettings::addXAxisSettingUI()
    {
        // QLabel* _axisX = new QLabel("横轴", this);
        //_axisX->setTextPixelSize(_titleFontSize);
        // 横轴标题
        // QLabel* _titleHTextX = new QLabel("横轴标题", this);
        auto _titleHTextX = new QTableWidgetItem("横轴标题");
        //_titleHTextX->setTextPixelSize(_titleFontSize);
        _titleHEditX = new QLineEdit(this);
        _titleHEditX->setText("x轴");

        // 字体
        // QLabel* _fontFamilyTextX = new QLabel("字体", this);
        auto _fontFamilyTextX = new QTableWidgetItem("字体");
        //_fontFamilyTextX->setTextPixelSize(_titleFontSize);
        _fontFamilyComboBoxX = new QComboBox(this);
        _fontFamilyComboBoxX->setView(new QListView());
        QStringList _fontFamilyComboListX{
            "宋体",
            "微软雅黑",
        };
        _fontFamilyComboBoxX->addItems(_fontFamilyComboListX);

        // 字号
        // QLabel* _fontSizeTextX = new QLabel("字号", this);
        auto _fontSizeTextX = new QTableWidgetItem("字号");
        //_fontSizeTextX->setTextPixelSize(_titleFontSize);
        _fontSizeInputX = new QSpinBox(this);

        // 最小值
        // QLabel* _minTextX = new QLabel("起点", this);
        auto _minTextX = new QTableWidgetItem("起点");
        //_minTextX->setTextPixelSize(_titleFontSize);
        _minInputX = new QDoubleSpinBox(this);
        _minInputX->setDecimals(6);
        _minInputX->setMinimum(-100000000.0);
        _minInputX->setMaximum(100000000.0);

        // 最大值
        // QLabel* _maxTextX = new QLabel("终点", this);
        auto _maxTextX = new QTableWidgetItem("终点");
        //_maxTextX->setTextPixelSize(_titleFontSize);
        _maxInputX = new QDoubleSpinBox(this);
        _maxInputX->setDecimals(6);
        _maxInputX->setMinimum(-100000000.0);
        _maxInputX->setMaximum(100000000.0);

        // 步长
        // QLabel* _stepTextX = new QLabel("步长", this);
        auto _stepTextX = new QTableWidgetItem("步长");
        _stepComboBoxX = new QComboBox(this);
        _stepComboBoxX->setView(new QListView());
        QStringList _stepComboListX{
            "自动",
            "手动",
        };
        _stepComboBoxX->addItems(_stepComboListX);
        //_stepTextX->setTextPixelSize(_titleFontSize);
        _setpInputX = new QDoubleSpinBox(this);
        _setpInputX->setDecimals(6);
        _setpInputX->setMinimum(0.000000001);
        _setpInputX->setMaximum(100000000.0);

        // 页面2的布局
        //_page2Layout->addWidget(_axisX, page2RowCount, 0);
        //_page2Layout->addWidget(_titleHTextX, ++page2RowCount, 0);
        //_page2Layout->addWidget(_titleHEditX, page2RowCount, 1);
        //_page2Layout->addWidget(_fontFamilyTextX, ++page2RowCount, 0);
        //_page2Layout->addWidget(_fontFamilyComboBoxX, page2RowCount, 1);
        //_page2Layout->addWidget(_fontSizeTextX, ++page2RowCount, 0);
        //_page2Layout->addWidget(_fontSizeInputX, page2RowCount, 1);
        //_page2Layout->addWidget(_minTextX, ++page2RowCount, 0);
        //_page2Layout->addWidget(_minInputX, page2RowCount, 1);
        //_page2Layout->addWidget(_maxTextX, page2RowCount, 2);
        //_page2Layout->addWidget(_maxInputX, page2RowCount, 3);
        //_page2Layout->addWidget(_stepTextX, ++page2RowCount, 0);
        //_page2Layout->addWidget(_setpInputX, page2RowCount, 1);
        QTableWidget* tableWidget = new QTableWidget(m_tabSetting);
        tableWidget->setRowCount(7);
        tableWidget->setColumnCount(2);
        tableWidget->setHorizontalHeaderLabels(QStringList() << "名称" << "值");
        tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
        tableWidget->setItem(0, 0, _titleHTextX);
        tableWidget->setCellWidget(0, 1, _titleHEditX);
        tableWidget->setItem(1, 0, _fontFamilyTextX);
        tableWidget->setCellWidget(1, 1, _fontFamilyComboBoxX);
        tableWidget->setItem(2, 0, _fontSizeTextX);
        tableWidget->setCellWidget(2, 1, _fontSizeInputX);
        tableWidget->setItem(3, 0, _minTextX);
        tableWidget->setCellWidget(3, 1, _minInputX);
        tableWidget->setItem(4, 0, _maxTextX);
        tableWidget->setCellWidget(4, 1, _maxInputX);
        tableWidget->setItem(5, 0, _stepTextX);
        tableWidget->setCellWidget(5, 1, _stepComboBoxX);
        tableWidget->setItem(6, 0, new QTableWidgetItem);
        tableWidget->setCellWidget(6, 1, _setpInputX);
        m_tabSetting->addTab(tableWidget, "横轴");
        // 设置第一列不可编辑
        for (int row = 0; row < tableWidget->rowCount(); ++row)
        {
            QTableWidgetItem* item = tableWidget->item(row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        connect(_titleHEditX, &QLineEdit::textChanged,
                this, [this]()
                { emit signal_XAxisTitleNameChanged(_titleHEditX->text()); });
        connect(_fontFamilyComboBoxX, QOverload<int>::of(&QComboBox::currentIndexChanged),
                this, [this]()
                { emit signal_XAxisTitleFontFamilyChanged(
                      getFontFamilyString(_fontFamilyComboBoxX->currentText())); });
        connect(_fontSizeInputX, QOverload<int>::of(&QSpinBox::valueChanged),
                this, [this]()
                { emit signal_XAxisTitleFontSizeChanged(_fontSizeInputX->value()); });
        connect(_minInputX, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
                this, [this]()
                { emit signal_XAxisMinValueChanged(_minInputX->value()); });
        connect(_maxInputX, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
                this, [this]()
                { emit signal_XAxisMaxValueChanged(_maxInputX->value()); });
        connect(_setpInputX, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
                this, [this]
                { emit signal_XAxisStepValueChanged(_setpInputX->value()); });
        connect(_stepComboBoxX, QOverload<int>::of(&QComboBox::currentIndexChanged),
                this, [this](int index)
                {
                if (index == 0)
                {
                    qobject_cast<QTableWidget*>(m_tabSetting->widget(0))->setRowHidden(6, true);
                    emit signal_XAxisStepValueChanged(-1);
                }
                else if (index == 1)
                {
                    qobject_cast<QTableWidget*>(m_tabSetting->widget(0))->setRowHidden(6, false);
                    emit signal_XAxisStepValueChanged(_setpInputX->value());
                } });

        tableWidget->setRowHidden(6, true);
        _stepComboBoxX->setCurrentIndex(0);
        //_setpInputX->setValue(5);
        _maxInputX->setValue(0.00002);
        _minInputX->setValue(0.00001);
        _fontSizeInputX->setValue(12);
        _fontFamilyComboBoxX->setCurrentIndex(0);
    }

    void TwoDHeatMapSettings::addYAxisSettingUI()
    {
        // QLabel* _axisY = new QLabel("纵轴", this);
        //_axisY->setTextPixelSize(_titleFontSize);
        // 横轴标题
        // QLabel* _titleHTextY = new QLabel("纵轴标题", this);
        auto _titleHTextY = new QTableWidgetItem("纵轴标题");
        //_titleHTextY->setTextPixelSize(_titleFontSize);
        _titleHEditY = new QLineEdit(this);
        _titleHEditY->setText("y轴");

        // 字体
        // QLabel* _fontFamilyTextY = new QLabel("字体", this);
        auto _fontFamilyTextY = new QTableWidgetItem("字体");
        //_fontFamilyTextY->setTextPixelSize(_titleFontSize);
        _fontFamilyComboBoxY = new QComboBox(this);
        _fontFamilyComboBoxY->setView(new QListView());
        QStringList _fontFamilyComboListY{
            "微软雅黑",
            "宋体",
        };
        _fontFamilyComboBoxY->addItems(_fontFamilyComboListY);

        // 字号
        // QLabel* _fontSizeTextY = new QLabel("字号", this);
        auto _fontSizeTextY = new QTableWidgetItem("字号");
        //_fontSizeTextY->setTextPixelSize(_titleFontSize);
        _fontSizeInputY = new QSpinBox(this);

        // 最小值
        // QLabel* _minTextY = new QLabel("起点", this);
        auto _minTextY = new QTableWidgetItem("起点");
        //_minTextY->setTextPixelSize(_titleFontSize);
        _minInputY = new QDoubleSpinBox(this);
        _minInputY->setDecimals(6);
        _minInputY->setMinimum(-100000000.0);
        _minInputY->setMaximum(100000000.0);

        // 最大值
        // QLabel* _maxTextY = new QLabel("终点", this);
        auto _maxTextY = new QTableWidgetItem("终点");
        //_maxTextY->setTextPixelSize(_titleFontSize);
        _maxInputY = new QDoubleSpinBox(this);
        _maxInputY->setDecimals(6);
        _maxInputY->setMinimum(-100000000.0);
        _maxInputY->setMaximum(100000000.0);

        // 步长
        // QLabel* _stepTextY = new QLabel("步长", this);
        auto _stepTextY = new QTableWidgetItem("步长");
        _stepComboBoxY = new QComboBox(this);
        _stepComboBoxY->setView(new QListView());
        QStringList _stepComboListY{
            "自动",
            "手动",
        };
        _stepComboBoxY->addItems(_stepComboListY);
        //_stepTextY->setTextPixelSize(_titleFontSize);
        _setpInputY = new QDoubleSpinBox(this);
        _setpInputY->setDecimals(6);
        _setpInputY->setMinimum(0.000000001);
        _setpInputY->setMaximum(100000000.0);

        // 页面2的布局
        //_page2Layout->addWidget(_axisY, ++page2RowCount, 0);
        //_page2Layout->addWidget(_titleHTextY, ++page2RowCount, 0);
        //_page2Layout->addWidget(_titleHEditY, page2RowCount, 1);
        //_page2Layout->addWidget(_fontFamilyTextY, ++page2RowCount, 0);
        //_page2Layout->addWidget(_fontFamilyComboBoxY, page2RowCount, 1);
        //_page2Layout->addWidget(_fontSizeTextY, ++page2RowCount, 0);
        //_page2Layout->addWidget(_fontSizeInputY, page2RowCount, 1);
        //_page2Layout->addWidget(_minTextY, ++page2RowCount, 0);
        //_page2Layout->addWidget(_minInputY, page2RowCount, 1);
        //_page2Layout->addWidget(_maxTextY, page2RowCount, 2);
        //_page2Layout->addWidget(_maxInputY, page2RowCount, 3);
        //_page2Layout->addWidget(_stepTextY, ++page2RowCount, 0);
        //_page2Layout->addWidget(_setpInputY, page2RowCount, 1);
        QTableWidget* tableWidget = new QTableWidget(m_tabSetting);
        tableWidget->setRowCount(7);
        tableWidget->setColumnCount(2);
        tableWidget->setHorizontalHeaderLabels(QStringList() << "名称" << "值");
        tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
        tableWidget->setItem(0, 0, _titleHTextY);
        tableWidget->setCellWidget(0, 1, _titleHEditY);
        tableWidget->setItem(1, 0, _fontFamilyTextY);
        tableWidget->setCellWidget(1, 1, _fontFamilyComboBoxY);
        tableWidget->setItem(2, 0, _fontSizeTextY);
        tableWidget->setCellWidget(2, 1, _fontSizeInputY);
        tableWidget->setItem(3, 0, _minTextY);
        tableWidget->setCellWidget(3, 1, _minInputY);
        tableWidget->setItem(4, 0, _maxTextY);
        tableWidget->setCellWidget(4, 1, _maxInputY);
        tableWidget->setItem(5, 0, _stepTextY);
        tableWidget->setCellWidget(5, 1, _stepComboBoxY);
        tableWidget->setItem(6, 0, new QTableWidgetItem);
        tableWidget->setCellWidget(6, 1, _setpInputY);
        m_tabSetting->addTab(tableWidget, "纵轴");
        // 设置第一列不可编辑
        for (int row = 0; row < tableWidget->rowCount(); ++row)
        {
            QTableWidgetItem* item = tableWidget->item(row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        connect(_titleHEditY, &QLineEdit::textChanged,
                this, [this]()
                { emit signal_YAxisTitleNameChanged(_titleHEditY->text()); });
        connect(_fontFamilyComboBoxY, QOverload<int>::of(&QComboBox::currentIndexChanged),
                this, [this]()
                { emit signal_YAxisTitleFontFamilyChanged(
                      getFontFamilyString(_fontFamilyComboBoxY->currentText())); });
        connect(_fontSizeInputY, QOverload<int>::of(&QSpinBox::valueChanged),
                this, [this]()
                { emit signal_YAxisTitleFontSizeChanged(_fontSizeInputY->value()); });
        connect(_minInputY, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
                this, [this]()
                { emit signal_YAxisMinValueChanged(_minInputY->value()); });
        connect(_maxInputY, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
                this, [this]()
                { emit signal_YAxisMaxValueChanged(_maxInputY->value()); });
        connect(_setpInputY, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
                this, [this]
                { emit signal_YAxisStepValueChanged(_setpInputY->value()); });
        connect(_stepComboBoxY, QOverload<int>::of(&QComboBox::currentIndexChanged),
                this, [this](int index)
                {
                if (index == 0)
                {
                    qobject_cast<QTableWidget*>(m_tabSetting->widget(1))->setRowHidden(6, true);
                    emit signal_YAxisStepValueChanged(-1);
                }
                else if (index == 1)
                {
                    qobject_cast<QTableWidget*>(m_tabSetting->widget(1))->setRowHidden(6, false);
                    emit signal_YAxisStepValueChanged(_setpInputY->value());
                } });

        tableWidget->setRowHidden(6, true);
        _stepComboBoxY->setCurrentIndex(0);
        //_setpInputY->setValue(5);
        _maxInputY->setValue(0.00002);
        _minInputY->setValue(0.00001);
        _fontSizeInputY->setValue(12);
        _fontFamilyComboBoxY->setCurrentIndex(0);
    }

    void TwoDHeatMapSettings::addCurvePropertyUI()
    {
        // 曲线
        // QLabel* curveText = new QLabel("曲线", this);
        // curveText->setTextPixelSize(_titleFontSize);

        // 曲线颜色
        // QLabel* curveColor = new QLabel("曲线颜色", this);
        auto curveColor = new QTableWidgetItem("曲线颜色");
        // curveColor->setTextPixelSize(_titleFontSize);
        BaseWidget::EColorComboBox* curveColorSelector = new BaseWidget::EColorComboBox(this);
        curveColorSelector->appendPredefinedColors();
        curveColorSelector->setEnabled(false);
        // 曲线粗细
        // QLabel* curveWidth = new QLabel("曲线粗细", this);
        auto curveWidth = new QTableWidgetItem("曲线粗细");
        // curveWidth->setTextPixelSize(_titleFontSize);
        QComboBox* curveWidthSelector = new QComboBox(this);
        curveWidthSelector->setView(new QListView());
        QStringList curveWidthList = {"0.25", "0.5", "0.75", "1", "1.5", "2.25", "3", "4.5", "6"};
        curveWidthSelector->addItems(curveWidthList);
        curveWidthSelector->setEnabled(false);

        //_page2Layout->addWidget(curveText, ++page2RowCount, 0);
        //_page2Layout->addWidget(curveColor, ++page2RowCount, 0);
        //_page2Layout->addWidget(curveColorSelector, page2RowCount, 1);
        //_page2Layout->addWidget(curveWidth, ++page2RowCount, 0);
        //_page2Layout->addWidget(curveWidthSelector, page2RowCount, 1);
        QTableWidget* tableWidget = new QTableWidget(m_tabSetting);
        tableWidget->setRowCount(2);
        tableWidget->setColumnCount(2);
        tableWidget->setHorizontalHeaderLabels(QStringList() << "名称" << "值");
        tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
        tableWidget->setItem(0, 0, curveColor);
        tableWidget->setCellWidget(0, 1, curveColorSelector);
        tableWidget->setItem(1, 0, curveWidth);
        tableWidget->setCellWidget(1, 1, curveWidthSelector);
        m_tabSetting->addTab(tableWidget, "曲线");
        // 设置第一列不可编辑
        for (int row = 0; row < tableWidget->rowCount(); ++row)
        {
            QTableWidgetItem* item = tableWidget->item(row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }
    }

    void TwoDHeatMapSettings::addLegendPropertyUI()
    {
        // 图例
        // QLabel* legendText = new QLabel("图例", this);
        // legendText->setTextPixelSize(_titleFontSize);

        // 字体
        // QLabel* fontFamilyText = new QLabel("字体", this);
        auto fontFamilyText = new QTableWidgetItem("字体");
        // fontFamilyText->setTextPixelSize(_titleFontSize);
        _legendFontFamilySelector = new QComboBox(this);
        _legendFontFamilySelector->setView(new QListView());
        QStringList _fontFamilyComboListX{
            "宋体",
            "微软雅黑",
        };
        _legendFontFamilySelector->addItems(_fontFamilyComboListX);
        connect(_legendFontFamilySelector, QOverload<int>::of(&QComboBox::currentIndexChanged),
                this, [this]()
                { emit signal_legendTitleFontFamilyChanged(_legendFontFamilySelector->currentText()); });

        // 字号
        // QLabel* fontSizeText = new QLabel("字号", this);
        auto fontSizeText = new QTableWidgetItem("字号");
        // fontSizeText->setTextPixelSize(_titleFontSize);
        _legendFontSizeSelector = new QComboBox(this);
        _legendFontSizeSelector->setView(new QListView());
        QStringList fontSize;
        for (int i = 1; i < 100; ++i)
        {
            fontSize << QString::number(i);
        }
        _legendFontSizeSelector->addItems(fontSize);
        _legendFontSizeSelector->setCurrentText("8");
        connect(_legendFontSizeSelector, QOverload<int>::of(&QComboBox::currentIndexChanged),
                this, [this]()
                { emit signal_legendTitleFontSizeChanged(_legendFontSizeSelector->currentText().toInt()); });

        //_page2Layout->addWidget(legendText, ++page2RowCount, 0);
        //_page2Layout->addWidget(fontFamilyText, ++page2RowCount, 0);
        //_page2Layout->addWidget(_legendFontFamilySelector, page2RowCount, 1);
        //_page2Layout->addWidget(fontSizeText, ++page2RowCount, 0);
        //_page2Layout->addWidget(_legendFontSizeSelector, page2RowCount, 1);
        QTableWidget* tableWidget = new QTableWidget(m_tabSetting);
        tableWidget->setRowCount(2);
        tableWidget->setColumnCount(2);
        tableWidget->setHorizontalHeaderLabels(QStringList() << "名称" << "值");
        tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
        tableWidget->setItem(0, 0, fontFamilyText);
        tableWidget->setCellWidget(0, 1, _legendFontFamilySelector);
        tableWidget->setItem(1, 0, fontSizeText);
        tableWidget->setCellWidget(1, 1, _legendFontSizeSelector);
        m_tabSetting->addTab(tableWidget, "图例");
        // 设置第一列不可编辑
        for (int row = 0; row < tableWidget->rowCount(); ++row)
        {
            QTableWidgetItem* item = tableWidget->item(row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }
    }

    void TwoDHeatMapSettings::disconnectSignals()
    {
        disconnect(ui->comboBox_TransverseVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
                   this, &TwoDHeatMapSettings::slot_variableAxisChanged);
        disconnect(ui->comboBox_LongitudinalVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
                   this, &TwoDHeatMapSettings::slot_secondVariableAxisChanged);
        disconnect(ui->comboBox_valueData, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TwoDHeatMapSettings::slot_resultValueDataChanged);
        disconnect(ui->checkBox_Normalize, &QCheckBox::clicked, this, &TwoDHeatMapSettings::slot_checkBoxNormalizeClicked);
        disconnect(ui->checkBox_DB, &QCheckBox::clicked, this, &TwoDHeatMapSettings::slot_checkBoxDBClicked);
    }

    void TwoDHeatMapSettings::connectSignals()
    {
        connect(ui->comboBox_TransverseVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
                this, &TwoDHeatMapSettings::slot_variableAxisChanged, Qt::UniqueConnection);
        connect(ui->comboBox_LongitudinalVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
                this, &TwoDHeatMapSettings::slot_secondVariableAxisChanged, Qt::UniqueConnection);
        connect(ui->comboBox_valueData, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TwoDHeatMapSettings::slot_resultValueDataChanged);
        connect(ui->checkBox_Normalize, &QCheckBox::clicked, this, &TwoDHeatMapSettings::slot_checkBoxNormalizeClicked);
        connect(ui->checkBox_DB, &QCheckBox::clicked, this, &TwoDHeatMapSettings::slot_checkBoxDBClicked);
    }

    void TwoDHeatMapSettings::hideComponents()
    {
        ui->label_categryValue->setVisible(false);
        ui->comboBox_categryValue->setVisible(false);
        ui->checkBox_MathOperation->setVisible(false);
        ui->lineEdit_FormulaEditor->setVisible(false);
        ui->pushButton_FormulaEditor->setVisible(false);

        DisableComponentCombox();
    }

    int TwoDHeatMapSettings::getResultDataComponent()
    {
        if (ui->radioButton_Amplitude->isChecked())
        {
            return 0;
        }
        else if (ui->radioButton_Phase->isChecked())
        {
            return 1;
        }
        else if (ui->radioButton_RealPart->isChecked())
        {
            return 2;
        }
        else if (ui->radioButton_ImaginaryPart->isChecked())
        {
            return 3;
        }
        return 0;
    }

    void TwoDHeatMapSettings::DisableComponentCombox()
    {
        ui->radioButton_Amplitude->setAutoExclusive(false);
        ui->radioButton_Amplitude->setEnabled(false);
        ui->radioButton_Amplitude->setChecked(false);
        ui->radioButton_Amplitude->setAutoExclusive(true);
        ui->radioButton_Phase->setAutoExclusive(false);
        ui->radioButton_Phase->setEnabled(false);
        ui->radioButton_Phase->setChecked(false);
        ui->radioButton_Phase->setAutoExclusive(true);
        ui->radioButton_RealPart->setAutoExclusive(false);
        ui->radioButton_RealPart->setEnabled(false);
        ui->radioButton_RealPart->setChecked(false);
        ui->radioButton_RealPart->setAutoExclusive(true);
        ui->radioButton_ImaginaryPart->setAutoExclusive(false);
        ui->radioButton_ImaginaryPart->setEnabled(false);
        ui->radioButton_ImaginaryPart->setChecked(false);
        ui->radioButton_ImaginaryPart->setAutoExclusive(true);
    }

    void TwoDHeatMapSettings::setFixedVariableValue(
        const QList<QPair<QString, QList<QString>>>& fixedValueList)
    {
        m_FixedVariableValueList = fixedValueList;
    }

    void TwoDHeatMapSettings::slot_fixedValueChanged()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        QList<int> allIndexList;
        for (auto i : m_fixedCombo)
        {
            allIndexList.append(i->currentIndex());
        }
        QString _allIndexList = GlobalHelperInstance->convertIntListToQString(allIndexList);

        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setFixedValueChanged(%1,\"%2\")").arg((int)m_mainWindowId).arg(_allIndexList);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        emit IBaseSignalInstance->signal_setHeatMapFixedValueChanged((int)m_mainWindowId, allIndexList);
    }

    void TwoDHeatMapSettings::slot_ComplexPartsClicked()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        bool isAmplitudeChecked = ui->radioButton_Amplitude->isChecked();
        bool isPhaseChecked = ui->radioButton_Phase->isChecked();
        bool isRealPartChecked = ui->radioButton_RealPart->isChecked();
        bool isImaginaryPartChecked = ui->radioButton_ImaginaryPart->isChecked();

        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setComplexPartsChanged(%1,%2,%3,%4,%5)").arg((int)m_mainWindowId).arg(isAmplitudeChecked).arg(isPhaseChecked).arg(isRealPartChecked).arg(isImaginaryPartChecked);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        emit IBaseSignalInstance->signal_setHeatMapComplexPartsChanged((int)m_mainWindowId, isAmplitudeChecked, isPhaseChecked, isRealPartChecked, isImaginaryPartChecked);
    }

    void TwoDHeatMapSettings::slot_variableAxisChanged(int index)
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        //// 设置回原值
        //if (m_isAddCurve == true)
        //{
        //    m_isAddCurve = false;
        //    return;
        //}

        auto allSelectedItem = ui->listView_curveName->selectionModel()->selectedIndexes();
        if (allSelectedItem.isEmpty())
        {
            return;
        }

        QString _typeName = ui->comboBox_TransverseVariable->currentText();

        int _reuslt = 0;
        emit IBaseSignalInstance->signal_sendQuestionMessageToUI(_reuslt, "切换变量", QString("当前变量为“%1”，切换变量将在新图中展示。").arg(m_lastVariableAxisText));

        // 设置回原值
        //m_isAddCurve = true;
        QSignalBlocker blocker(ui->comboBox_TransverseVariable);
        ui->comboBox_TransverseVariable->setCurrentText(m_lastVariableAxisText);
        m_lastVariableAxisText = ui->comboBox_TransverseVariable->currentText();
        if ((int)EDialogMsgResult::Second != _reuslt)
        {
            return;
        }

        emit IWidgetSignalInstance->signal_exitAddMarkerState();

        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setVariableAxisChanged(%1,%2)").arg((int)m_mainWindowId).arg(index);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes,true,false);

        emit IBaseSignalInstance->signal_setHeatMapVariableAxisChanged((int)m_mainWindowId, index);
    }

    void TwoDHeatMapSettings::slot_secondVariableAxisChanged(int index)
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        //{
        //    QSignalBlocker blocker(ui->comboBox_LongitudinalVariable); // 开始阻断 signal
        //    ui->comboBox_LongitudinalVariable->setCurrentIndex(index);
        //}
        //// 设置回原值
        //if (m_isSecondAddCurve == true)
        //{
        //    m_isSecondAddCurve = false;
        //    return;
        //}

        auto allSelectedItem = ui->listView_curveName->selectionModel()->selectedIndexes();
        if (allSelectedItem.isEmpty())
        {
            return;
        }

        //emit IWidgetSignalInstance->signal_exitAddMarkerState();

        QString _typeName = ui->comboBox_LongitudinalVariable->currentText();

        int _reuslt = 0;
        emit IBaseSignalInstance->signal_sendQuestionMessageToUI(_reuslt, "切换变量", QString("当前变量为“%1”，切换变量将在新图中展示。").arg(m_lastSecondVariableAxisText));

        // 设置回原值
        //m_isSecondAddCurve = true;
        QSignalBlocker blocker(ui->comboBox_LongitudinalVariable);
        ui->comboBox_LongitudinalVariable->setCurrentText(m_lastSecondVariableAxisText);
        m_lastSecondVariableAxisText = ui->comboBox_LongitudinalVariable->currentText();
        if ((int)EDialogMsgResult::Second != _reuslt)
        {
            return;
        }

        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setSecondVariableAxisChanged(%1,%2)").arg((int)m_mainWindowId).arg(index);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        emit IBaseSignalInstance->signal_setHeatMapSecondVariableAxisChanged((int)m_mainWindowId, index);
    }

    // 选中曲线后，判断所有选中曲线的信息，根据信息设置下面框的内内容
    void TwoDHeatMapSettings::slot_curveNameClicked()
    {
        // TODO 发送信号给graph，通知选中该曲线

        auto allSelectedItem = ui->listView_curveName->selectionModel()->selectedIndexes();
        QString dataSource;
        bool _isLegalSource = true;
        QList<int> selectedIndexs;
        for (const auto& i : allSelectedItem)
        {
            selectedIndexs.append(i.row());
            if (_isLegalSource)
            {
                // 获取数据来源（项目树）
                QString _itemText = i.data().toString();
                auto* model = qobject_cast<QStandardItemModel*>(ui->listView_curveName->model());
                emit signal_getSidebarCurveDataSource(model->item(i.row()), _itemText);
                if (dataSource.isEmpty() || dataSource.contains(_itemText))
                    dataSource = _itemText;
                else
                {
                    dataSource = "";
                    _isLegalSource = false;
                }
            }
        }
        //ui->textEdit_DataSource->setText(dataSource);
        QString sselectedIndexs = GlobalHelperInstance->convertIntListToQString(selectedIndexs);
        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setSelectedCurveNameIndexs(%1,\"%2\")").arg((int)m_mainWindowId).arg(sselectedIndexs);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        emit IBaseSignalInstance->signal_setHeatMapSelectedCurveNameIndexs((int)m_mainWindowId, selectedIndexs);
        ui->textEdit_DataSource->setText(dataSource);
    }

    void TwoDHeatMapSettings::slot_curveNameCheckStateChanged(QStandardItem* item)
    {
        auto _checkState = int(item->checkState());
        if (!item->data(Qt::UserRole).isNull()) // 如果item的data为空或新状态和之前不一致则更新
        {
            auto _oldState = item->data(Qt::UserRole).toInt();
            if (_oldState != _checkState)
            {
                item->setData(_checkState, Qt::UserRole);
            }
            else
            {
                return;
            }
        }
        else
            item->setData(_checkState, Qt::UserRole);
        QStandardItemModel* model = (QStandardItemModel*)ui->listView_curveName->model();
        int index = model->indexFromItem(item).row();
        bool checkState = item->checkState() == Qt::Checked ? true : false;
        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setCurveNameCheckStateChanged(%1,%2,%3)").arg((int)m_mainWindowId).arg(index).arg(checkState);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        emit IBaseSignalInstance->signal_setHeatMapCurveNameCheckStateChanged((int)m_mainWindowId, index, checkState);
    }

    void TwoDHeatMapSettings::slot_updateCurveData()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        QVector<int> otherKeyIndex;
        auto allSelectedItem = ui->listView_curveName->selectionModel()->selectedIndexes();
        if (allSelectedItem.isEmpty())
        {
            return;
        }

        emit IWidgetSignalInstance->signal_exitAddMarkerState();

        //QList<QStandardItem*> itemList;
        QList<int> _selectedCurveInfoIDList;
        auto _graphWindow = WindowTotalDataInstance->getGraph2DWindowByID(m_windowUniversalID);
        QStandardItemModel* model = (QStandardItemModel*)ui->listView_curveName->model();
        for (const auto& i : allSelectedItem)
        {
            auto _info = _graphWindow->getCurveInfoByItem(model->itemFromIndex(i));
            _selectedCurveInfoIDList.append(_info->getInformationID());
            //itemList.append(model->itemFromIndex(i));
        }
        // 根据当前选择数据生成一个新的tempInfo
        // 根据当前的需求，新生成的tempInfo只需要存储  归一化和db信息是否发生更改，其他信息从自身的Info获取
        Info2DPointer tempInfo = Info2DPointer::create();
        auto _tempInfoID = WindowTotalDataInstance->getGraph2DInformationMaxID();
        tempInfo->setInformationID(_tempInfoID);
        WindowTotalDataInstance->appendInfomationCurve2DBasical(tempInfo);
        if (_selectedCurveInfoIDList.size() > 1)
        {
            tempInfo->setIsMuti(true);
        }
        else // 单选才需要记录固定值和value
        {
            // 固定值
            QVector<double> fixedValue;
            for (auto i : m_fixedCombo)
            {
                otherKeyIndex.append(i->currentIndex());
                fixedValue.append(i->currentText().toDouble());
            }
            // value
            auto currentValueIndex = ui->comboBox_valueData->currentIndex();
            int valueComponent = getResultDataComponent();

            tempInfo->setOtherKeyData(fixedValue);
            tempInfo->setValueIndex(currentValueIndex);
            tempInfo->setValueComponent(valueComponent);
            tempInfo->setIsDBState(m_currentTempInfo->getIsDBState());
        }
        tempInfo->setIsDB(ui->checkBox_DB->isChecked());
        tempInfo->setIsNormalized(ui->checkBox_Normalize->isChecked());
        tempInfo->setCurveLineAddress(m_currentTempInfo->getCurveLineAddress());
        emit signal_updateCurveData(_selectedCurveInfoIDList, _tempInfoID, otherKeyIndex);
    }

    void TwoDHeatMapSettings::slot_resultValueDataChanged(int index)
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();

        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setResultValueDataChanged(%1,%2)").arg((int)m_mainWindowId).arg(index);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        emit IBaseSignalInstance->signal_setHeatMapResultValueDataChanged((int)m_mainWindowId, index);
    }

    // 界面点过之后，都变为2态
    void TwoDHeatMapSettings::slot_checkBoxNormalizeClicked()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        auto isLog = ui->checkBox_DB->isChecked();
        auto isNormalize = ui->checkBox_Normalize->isChecked();

        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setDataOprationChanged(%1,%2,%3)").arg((int)m_mainWindowId).arg(isLog).arg(isNormalize);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        emit IBaseSignalInstance->signal_setHeatMapDataOprationChanged((int)m_mainWindowId, isLog, isNormalize);
    }

    void TwoDHeatMapSettings::slot_checkBoxDBClicked()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        auto isLog = ui->checkBox_DB->isChecked();
        auto isNormalize = ui->checkBox_Normalize->isChecked();
        m_currentTempInfo->setIsDBState(isLog);

        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setDataOprationChanged(%1,%2,%3)").arg((int)m_mainWindowId).arg(isLog).arg(isNormalize);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        emit IBaseSignalInstance->signal_setHeatMapDataOprationChanged((int)m_mainWindowId, isLog, isNormalize);
    }

    void TwoDHeatMapSettings::slot_removeSelectedGraph()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setRemoveSelectedGraph(%1)").arg((int)m_mainWindowId);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        emit IBaseSignalInstance->signal_setHeatMapRemoveSelectedGraph((int)m_mainWindowId);
    }

    void TwoDHeatMapSettings::slot_renameFinished()
    {
        emit IWidgetSignalInstance->signal_exitAddMarkerState();
        QModelIndexList selectedIndexes = ui->listView_curveName->selectionModel()->selectedIndexes();
        if (selectedIndexes.size() != 1)
        {
            return;
        }

        auto name = ui->listView_curveName->model()->data(selectedIndexes.first()).toString();
        if (name.isEmpty())
        {
            EDialogMsgResult _result = IdaDialogMsg::showDialog(this, QString("命名不能为空，请重新编辑。"), EDialogMsg::Error, tr("重命名错误"));
            ui->listView_curveName->model()->setData(selectedIndexes[0], m_currentTempInfo->getCurveName());
            return;
        }

        QStringList _pyCodes{};
        _pyCodes += QString("twodlinechart = PostProcessing.TwoDLineChart()");
        _pyCodes += QString("twodlinechart.setRenameFinished(%1,\"%2\")").arg((int)m_mainWindowId).arg(name);
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        emit IBaseSignalInstance->signal_setHeatMapRenameFinished((int)m_mainWindowId, name);
    }

    void TwoDHeatMapSettings::slot_xAxisRangeChange(double minValue, double maxValue)
    {
        //_minInputX->blockSignals(true);
        //_minInputX->setValue(minValue);
        //_minInputX->blockSignals(false);
        //_maxInputX->blockSignals(true);
        //_maxInputX->setValue(maxValue);
        //_maxInputX->blockSignals(false);
    }

    void TwoDHeatMapSettings::slot_yAxisRangeChange(double minValue, double maxValue)
    {
        //_minInputY->blockSignals(true);
        //_minInputY->setValue(minValue);
        //_minInputY->blockSignals(false);
        //_maxInputY->blockSignals(true);
        //_maxInputY->setValue(maxValue);
        //_maxInputY->blockSignals(false);
    }

    void TwoDHeatMapSettings::secondVariableAxisChanged(int index)
    {
        auto allSelectedItem = ui->listView_curveName->selectionModel()->selectedIndexes();
        if (allSelectedItem.isEmpty())
        {
            return;
        }

        {
            QSignalBlocker blocker(ui->comboBox_LongitudinalVariable);
            ui->comboBox_LongitudinalVariable->setCurrentIndex(index); // 恢复成切换一次的状态
        }

        // 根据当前选择数据生成一个新的tempInfo
        // 根据当前的需求，新生成的tempInfo只需要存储新的变量轴
        //Info2DPointer tempInfo = Info2DPointer::create(*m_currentTempInfo);
        Info2DPointer tempInfo = Info2DPointer::create();
        // if (itemList.size() > 1)
        //{
        //     tempInfo.setIsMuti(true);
        // }
        tempInfo->setSecondScanParameterName(ui->comboBox_LongitudinalVariable->currentText());
        if (ui->comboBox_TransverseVariable->currentText() == ui->comboBox_LongitudinalVariable->currentText())
        {
            tempInfo->setScanParameterName(m_lastSecondVariableAxisText);
        }
        else
        {
            tempInfo->setScanParameterName(ui->comboBox_TransverseVariable->currentText());
        }

        if (m_currentTempInfo)
        {
            tempInfo->setVarValueList(m_currentTempInfo->getVarValueList());
            tempInfo->setUnit(m_currentTempInfo->getUnit());
            tempInfo->setFieldType(m_currentTempInfo->getFieldType());
        }

        emit signal_generateANewGraphCurve(allSelectedItem, tempInfo);

        // 设置回原值
        //m_isSecondAddCurve = true;
        disconnect(ui->comboBox_LongitudinalVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
            this, &TwoDHeatMapSettings::slot_secondVariableAxisChanged);
        ui->comboBox_LongitudinalVariable->setCurrentText(m_lastSecondVariableAxisText);
        connect(ui->comboBox_LongitudinalVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
            this, &TwoDHeatMapSettings::slot_secondVariableAxisChanged, Qt::UniqueConnection);
        m_lastSecondVariableAxisText = ui->comboBox_LongitudinalVariable->currentText();
    }

    void TwoDHeatMapSettings::variableAxisChanged(int index)
    {
        auto allSelectedItem = ui->listView_curveName->selectionModel()->selectedIndexes();
        if (allSelectedItem.isEmpty())
        {
            return;
        }

        {
            QSignalBlocker blocker(ui->comboBox_TransverseVariable);
            ui->comboBox_TransverseVariable->setCurrentIndex(index); // 恢复成切换一次的状态
        }

        // 根据当前选择数据生成一个新的tempInfo
        // 根据当前的需求，新生成的tempInfo只需要存储新的变量轴
        //Info2DPointer tempInfo = Info2DPointer::create(*m_currentTempInfo);
        Info2DPointer tempInfo = Info2DPointer::create();
        // if (itemList.size() > 1)
        //{
        //     tempInfo.setIsMuti(true);
        // }
        tempInfo->setScanParameterName(ui->comboBox_TransverseVariable->currentText());
        if (ui->comboBox_TransverseVariable->currentText() == ui->comboBox_LongitudinalVariable->currentText())
        {
            tempInfo->setSecondScanParameterName(m_lastVariableAxisText);
        }
        else
        {
            tempInfo->setSecondScanParameterName(ui->comboBox_LongitudinalVariable->currentText());
        }
        if (m_currentTempInfo)
        {
            tempInfo->setVarValueList(m_currentTempInfo->getVarValueList());
            tempInfo->setUnit(m_currentTempInfo->getUnit());
            tempInfo->setFieldType(m_currentTempInfo->getFieldType());
            tempInfo->setProjectTreeSourceItem(m_currentTempInfo->getProjectTreeSourceItem());
        }
        emit signal_generateANewGraphCurve(allSelectedItem, tempInfo);

        // 设置回原值
        //m_isAddCurve = true;
        disconnect(ui->comboBox_TransverseVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
            this, &TwoDHeatMapSettings::slot_variableAxisChanged);
        ui->comboBox_TransverseVariable->setCurrentText(m_lastVariableAxisText);
        connect(ui->comboBox_TransverseVariable, QOverload<int>::of(&QComboBox::currentIndexChanged),
            this, &TwoDHeatMapSettings::slot_variableAxisChanged, Qt::UniqueConnection);
        m_lastVariableAxisText = ui->comboBox_TransverseVariable->currentText();
    }

    void TwoDHeatMapSettings::curveNameCheckStateChanged(int index, bool checked)
    {
        auto model = (QStandardItemModel*)ui->listView_curveName->model();
        auto item = model->itemFromIndex(model->index(index, 0));

        {
            QSignalBlocker blocker(ui->listView_curveName);
            item->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
        }
        emit signal_showHideItemActor(item);
    }

    void TwoDHeatMapSettings::fixedValueChanged(QList<int> indexList)
    {
        for (int i = 0; i < indexList.size(); i++)
        {
            QSignalBlocker blocker(m_fixedCombo[i]);
            m_fixedCombo[i]->setCurrentIndex(indexList[i]);
        }
        this->slot_updateCurveData();
    }

    void TwoDHeatMapSettings::complexPartsChanged(bool isAmplitudeChecked, bool isPhaseChecked, bool isRealPartChecked, bool isImaginaryPartChecked)
    {
        QSignalBlocker blocker(ui->radioButton_Amplitude);
        ui->radioButton_Amplitude->setChecked(isAmplitudeChecked);

        QSignalBlocker blocker1(ui->radioButton_Phase);
        ui->radioButton_Phase->setChecked(isPhaseChecked);

        QSignalBlocker blocker2(ui->radioButton_RealPart);
        ui->radioButton_RealPart->setChecked(isRealPartChecked);

        QSignalBlocker blocker3(ui->radioButton_ImaginaryPart);
        ui->radioButton_ImaginaryPart->setChecked(isImaginaryPartChecked);

        if (isAmplitudeChecked)
        {
            ui->checkBox_DB->setEnabled(true);
            ui->checkBox_DB->setChecked(m_currentTempInfo->getIsDBState());
        }
        else if (isPhaseChecked)
        {
            ui->checkBox_DB->setEnabled(false);
            ui->checkBox_DB->setChecked(false);
        }
        else if (isRealPartChecked)
        {
            ui->checkBox_DB->setEnabled(false);
            ui->checkBox_DB->setChecked(false);
        }
        else if (isImaginaryPartChecked)
        {
            ui->checkBox_DB->setEnabled(false);
            ui->checkBox_DB->setChecked(false);
        }

        this->slot_updateCurveData();
    }

    void TwoDHeatMapSettings::removeSelectedGraph()
    {
        emit signal_removeSelectedGraph();
    }

    void TwoDHeatMapSettings::renameFinished(QString name)
    {
        emit signal_renameFinished(name);
    }
} // namespace pst
